home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / mordor_2.000 / mordor_2 / src / dm4.c < prev    next >
C/C++ Source or Header  |  1995-04-09  |  21KB  |  796 lines

  1. /*
  2.  * DM4.C:
  3.  *
  4.  *  DM functions
  5.  *
  6.  *  Copyright (C) 1991, 1992, 1993 Brett J. Vickers
  7.  *
  8.  */
  9.  
  10. #include "mstruct.h"
  11. #include "mextern.h"
  12.  
  13. #include <ctype.h>
  14.  
  15. /************************************************************************/
  16. /*              dm_param                */
  17. /************************************************************************/
  18.  
  19. int dm_param(ply_ptr, cmnd)
  20. creature    *ply_ptr;
  21. cmd     *cmnd;
  22. {
  23.     int     fd;
  24.     extern short   Random_update_interval;
  25.     extern long   TX_interval; 
  26.     extern long   last_exit_update;
  27.     long           t;
  28.  
  29.     fd = ply_ptr->fd;
  30.  
  31.     if(ply_ptr->class < CARETAKER)
  32.         return(PROMPT);
  33.  
  34.     if(cmnd->num < 2) {
  35.         print(fd, "Set what parameter?\n");
  36.         return;
  37.     }
  38.  
  39.         t = time(0);
  40.  
  41.  
  42.     switch(low(cmnd->str[1][0])) {
  43.     case 'r': Random_update_interval = cmnd->val[1]; return(PROMPT);
  44.     case 'd': 
  45.         print(fd,"Random Update: %d\n",Random_update_interval);
  46.         print(fd,"Time to next shutdown: %ld\n", (Shutdown.ltime +
  47.             Shutdown.interval) -t);
  48.         print(fd,"Ship sailing interval %ld\n",TX_interval);
  49.         print(fd,"Time to Sail: %ld\n", (last_exit_update + TX_interval)-t);
  50.         return (PROMPT);
  51.     case 's':
  52.     if( cmnd->val[1] == 1)
  53.         last_exit_update = t - TX_interval;
  54.     else
  55.             TX_interval = cmnd->val[1];
  56.         return(PROMPT);
  57.     default: print(fd, "Invalid parameter.\n");
  58.          return(0);
  59.     }
  60.  
  61. }
  62.  
  63.  
  64. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  65. /*                          dm_silence                                */
  66. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  67. /* DM_silence allows the dm to remove a specified player's dialy      *
  68.  * bbroadcasts. If only the player name is given then the player's     *
  69.  * is set to 0, if more that 2 arguemwnts are given, then the persons *
  70.  * broadcast is set to the given number. */
  71.  
  72. int dm_silence(ply_ptr, cmnd)
  73. creature    *ply_ptr;
  74. cmd     *cmnd;
  75. {
  76.     creature    *crt_ptr;
  77.     int fd, num;
  78.  
  79.     fd = ply_ptr->fd;
  80.  
  81.     if(ply_ptr->class < CARETAKER)
  82.         return(PROMPT);
  83.  
  84.     if(cmnd->num < 2) {
  85.         print(fd, "syntax: *silence <player> [c/m] [value]\n");
  86.         return(0);
  87.     }
  88.  
  89.  
  90.     lowercize(cmnd->str[1], 1);
  91.     crt_ptr = find_who(cmnd->str[1]);
  92.  
  93.     if(!crt_ptr || F_ISSET(crt_ptr, PDMINV) ){
  94.         print(fd, "That player is not logged on.\n");
  95.         return(0);
  96.     }
  97.  
  98.  
  99.     if(cmnd->num < 3) {
  100.         crt_ptr->daily[DL_BROAD].cur = 0;
  101.         crt_ptr->daily[DL_BROAD].ltime = time(0);
  102.         print(fd,"%M is silenced.\n",crt_ptr->name);
  103.     }
  104.     else if (low(cmnd->str[2][0]) == 'c')
  105.     {
  106.         print(fd,"%M has %d of %d broadcasts left.\n",crt_ptr->name,
  107.         crt_ptr->daily[DL_BROAD].cur,crt_ptr->daily[DL_BROAD].max);
  108.     }
  109.     else
  110.     {
  111.         crt_ptr->daily[DL_BROAD].ltime = time(0);
  112.         crt_ptr->daily[DL_BROAD].cur = cmnd->val[2];
  113.         print(fd,"%M is given %d broadcasts.\n",crt_ptr->name,
  114.             crt_ptr->daily[DL_BROAD].cur);
  115.     }
  116.      
  117.     return(0);
  118. }
  119. /**********************************************************************/
  120. /*                           dm_broadecho                             */
  121. /**********************************************************************/
  122.  
  123. /* dm_broadecho allows a DM to broadcast a message to                 *
  124.  * the players in the game free of any message format. i.e. the msg   *
  125.  * broadcasted appears exactly as it is typed */
  126.  
  127. int dm_broadecho(ply_ptr, cmnd)
  128. creature        *ply_ptr;
  129. cmd             *cmnd;
  130. {
  131.         int     i, found=0, fd;
  132.     int len;
  133.  
  134.         fd = ply_ptr->fd;
  135.  
  136.     if(ply_ptr->class < DM)
  137.         return(PROMPT);
  138.  
  139.     len = strlen(cmnd->fullstr);
  140.         for(i=0; i<len && i < 256; i++) {
  141.                 if(cmnd->fullstr[i] == ' ' && cmnd->fullstr[i+1] != ' ')
  142.                         found++;
  143.                 if(found==1) break;
  144.         }
  145.         cmnd->fullstr[255] = 0;
  146.     
  147.     len = strlen(&cmnd->fullstr[i+1]); 
  148.     if(found < 1 || len < 1) {
  149.                 print(fd, "echo what?\n");
  150.                 return(0);
  151.         }
  152.     if (cmnd->fullstr[i+1] == '-')
  153.         switch(cmnd->fullstr[i+2]){
  154.            case 'n':
  155.             if(cmnd->fullstr[i+3] != 0 && cmnd->fullstr[i+4] != 0)
  156.              broadcast("%s", &cmnd->fullstr[i+4]);
  157.              break;
  158.         }
  159.     else
  160.         broadcast("### %s", &cmnd->fullstr[i+1]);
  161.         return(0);
  162.  
  163. }
  164.  
  165.  
  166.  
  167. /***********************************************************************/
  168. /*                              dm_cast                                */
  169. /***********************************************************************/
  170.  
  171. int dm_cast(ply_ptr, cmnd)
  172. creature    *ply_ptr;
  173. cmd         *cmnd;
  174. {          
  175.     char    match=0,rcast = 0, *sp;
  176.     int     splno =0,c = 0, fd, i;
  177.     ctag    *cp;
  178. static    int    dm_gspells();
  179.  
  180.     fd = ply_ptr->fd;
  181.  
  182.  
  183.        if(ply_ptr->class < CARETAKER)
  184.                return(PROMPT);
  185.  
  186.         if(cmnd->num < 2) {
  187.                 print(fd, "Globally cast what?\n");
  188.                 return(PROMPT);
  189.         }
  190.          
  191.         if (cmnd->num >2 )    {
  192.             if (!strcmp(cmnd->str[1],"-r"))
  193.                 rcast = 1;
  194.             else {
  195.                 print(fd,"Invalid cast flag.\n");
  196.                 return(PROMPT);
  197.             }
  198.             sp = cmnd->str[2];
  199.         }
  200.         else if (cmnd->num == 2)
  201.             sp = cmnd->str[1];
  202.  
  203.    do {
  204.         if(!strcmp(sp, spllist[c].splstr)) {
  205.             match = 1;
  206.             splno = c;
  207.             break;
  208.         }
  209.         else if(!strncmp(sp, spllist[c].splstr, 
  210.             strlen(sp))) {
  211.             match++;
  212.             splno = c;
  213.         }
  214.         c++;
  215.     } while(spllist[c].splno != -1);
  216.  
  217.     if(match == 0) {
  218.         print(fd, "That spell does not exist.\n");
  219.         return(0);
  220.     }    
  221.     else if(match > 1) {
  222.         print(fd, "Spell name is not unique.\n");
  223.         return(0);
  224.     }
  225.  
  226.  
  227.     if(rcast){
  228.  
  229.         cp = ply_ptr->parent_rom->first_ply;
  230.  
  231.         if (splno == SRECAL){
  232.             ctag        *cp_tmp;
  233.             creature *pp;
  234.             room        *new_rom;
  235.  
  236.                 if(load_rom(1, &new_rom) < 0) {
  237.                     print(fd, "Spell failure.\n");
  238.                     return(0);
  239.                 }
  240.             print(fd,"You cast %s on everyone in the room.\n",
  241.                 spllist[splno].splstr);
  242.             broadcast_rom(fd, ply_ptr->rom_num,
  243.                 "%M casts %s on everyone in the room.\n",
  244.                 ply_ptr,spllist[splno].splstr);
  245.  
  246.         while(cp){
  247.             print(cp->crt->fd,"%M casts %s on you.\n",
  248.                 ply_ptr,spllist[splno].splstr);
  249.             cp_tmp=cp->next_tag;
  250.             pp = cp->crt;
  251.                     del_ply_rom(cp->crt, cp->crt->parent_rom);
  252.                     add_ply_rom(pp, new_rom);
  253.             cp = cp_tmp;
  254.         }
  255.             return(0);
  256.         }                        
  257.         while(cp){
  258.  
  259.  
  260.             if (F_ISSET(cp->crt,PDMINV)){
  261.                 cp = cp->next_tag;
  262.                 continue;
  263.             }
  264.             if ((c = dm_gspells(cp->crt,splno))){
  265.                 print(fd,"Sorry, you can not room cast that spell.\n");
  266.                 break;
  267.             }
  268.  
  269.             print(cp->crt->fd,"%M casts %s on you.\n",
  270.             ply_ptr,spllist[splno].splstr);
  271.             cp = cp->next_tag;
  272.         }
  273.  
  274.         if (!c){
  275.             print(fd,"You cast %s on everyone in the room.\n",
  276.                 spllist[splno].splstr);
  277.             broadcast_rom(fd, ply_ptr->rom_num,
  278.                 "%M casts %s on everyone in the room.\n",
  279.                 ply_ptr,spllist[splno].splstr);
  280.         }
  281.  
  282.         }
  283.         else{
  284.             for(i=0; i<Tablesize; i++) {
  285.                 if(!Ply[i].ply) continue;
  286.                 if(Ply[i].ply->fd == -1) continue;
  287.                 if(Ply[i].ply->fd == fd) continue;
  288.                 if(F_ISSET(Ply[i].ply, PDMINV)) continue;
  289.                 if ((c=dm_gspells(Ply[i].ply,splno))){
  290.                     print(fd,"Sorry, you can not globally cast that spell.\n");
  291.                     break;
  292.                 }
  293.                 print(Ply[i].ply->fd,"%M casts %s on you.\n",
  294.                 ply_ptr,spllist[splno].splstr);
  295.                 }
  296.             if (!c){
  297.                 print(fd,"You cast %s on everyone.\n", spllist[splno].splstr);
  298.                 broadcast("%M casts %s on everyone.\n",ply_ptr,
  299.                     spllist[splno].splstr);
  300.             }
  301.  
  302.         }
  303.  
  304.     return(0);
  305. }
  306.  
  307. /*========================================================================*/
  308. /*                                dm_gspells                                  */
  309. /*========================================================================*/
  310. static int    dm_gspells(ply_ptr,splno)
  311. creature    *ply_ptr;
  312. int            splno;
  313. {
  314.     long    t;
  315.  
  316.     t = time(0);
  317.             switch(splno){
  318.                 case SVIGOR:
  319.                     ply_ptr->hpcur += mrand(1,6) + 4 + 2;
  320.                     ply_ptr->hpcur = MIN(ply_ptr->hpcur,ply_ptr->hpmax);
  321.                 break;
  322.                 case SMENDW:
  323.                     ply_ptr->hpcur += mrand(2,10) + 4 + 4;
  324.                     ply_ptr->hpcur = MIN(ply_ptr->hpcur,ply_ptr->hpmax);
  325.                 break;
  326.                 case SRESTO:
  327.                     ply_ptr->hpcur = ply_ptr->hpmax;
  328.                     ply_ptr->mpcur = ply_ptr->mpmax;
  329.                 break;
  330.                 case SFHEAL:
  331.                     ply_ptr->hpcur = ply_ptr->hpmax;
  332.                 break;
  333.                 case SBLESS:
  334.                     ply_ptr->lasttime[LT_BLESS].interval = 3600;
  335.                     ply_ptr->lasttime[LT_BLESS].ltime = t;
  336.                     F_SET(ply_ptr,PBLESS);
  337.                 break;
  338.                 case SPROTE:
  339.                     ply_ptr->lasttime[LT_PROTE].interval = 3600;
  340.                     ply_ptr->lasttime[LT_PROTE].ltime = t;
  341.                     F_SET(ply_ptr,PPROTE);
  342.                 break;
  343.                 case SINVIS:
  344.                     ply_ptr->lasttime[LT_INVIS].interval = 3600;
  345.                     ply_ptr->lasttime[LT_INVIS].ltime = t;
  346.                     F_SET(ply_ptr,PINVIS);
  347.                 break;
  348.                 case SDMAGI:
  349.                     ply_ptr->lasttime[LT_DMAGI].interval = 3600;
  350.                     ply_ptr->lasttime[LT_DMAGI].ltime = t;
  351.                     F_SET(ply_ptr,PDMAGI);
  352.                 break;
  353.                 case SRFIRE:
  354.                     ply_ptr->lasttime[LT_RFIRE].interval = 3600;
  355.                     ply_ptr->lasttime[LT_RFIRE].ltime = t;
  356.                     F_SET(ply_ptr,PRFIRE);
  357.                 break;
  358.                 case SRMAGI:
  359.                     ply_ptr->lasttime[LT_RMAGI].interval = 3600;
  360.                     ply_ptr->lasttime[LT_RMAGI].ltime = t;
  361.                     F_SET(ply_ptr,PRMAGI);
  362.                 break;
  363.                 case SDINVI:
  364.                     ply_ptr->lasttime[LT_DINVI].interval = 3600;
  365.                     ply_ptr->lasttime[LT_DINVI].ltime = t;
  366.                     F_SET(ply_ptr,PDINVI);
  367.                 break;
  368.                 case SFLYSP:
  369.                     ply_ptr->lasttime[LT_FLYSP].interval = 3600;
  370.                     ply_ptr->lasttime[LT_FLYSP].ltime = t;
  371.                     F_SET(ply_ptr,PFLYSP);
  372.                 break;
  373.                 case SLIGHT:
  374.                     ply_ptr->lasttime[LT_LIGHT].interval = 3600;
  375.                     ply_ptr->lasttime[LT_LIGHT].ltime = t;
  376.                     F_SET(ply_ptr,PLIGHT);
  377.                 break;
  378.                 case SLEVIT:
  379.                     ply_ptr->lasttime[LT_LEVIT].interval = 3600;
  380.                     ply_ptr->lasttime[LT_LEVIT].ltime = t;
  381.                     F_SET(ply_ptr,PLEVIT);
  382.                 break;
  383.                 case SKNOWA:
  384.                     ply_ptr->lasttime[LT_KNOWA].interval = 3600;
  385.                     ply_ptr->lasttime[LT_KNOWA].ltime = t;
  386.                     F_SET(ply_ptr,PKNOWA);
  387.                 break;
  388.                     case SCUREP:
  389.                     F_CLR(ply_ptr,PPOISN);
  390.                 break;
  391.                 case SRMDIS:
  392.                     F_CLR(ply_ptr,PDISEA);
  393.                 break;
  394.                 default:
  395.                     return(1); 
  396.                 break;
  397.                 }
  398.     return(0);
  399. }
  400.  
  401.  
  402. /**********************************************************************/
  403. /*                dm_group                      */
  404. /**********************************************************************/
  405.  
  406. /* This function allows you to see who is in a group or party of people */
  407. /* who are following you.                        */
  408.  
  409. int dm_group(ply_ptr, cmnd)
  410. creature    *ply_ptr;
  411. cmd        *cmnd;
  412. {
  413.     ctag    *cp;
  414.     room    *rom_ptr;
  415.     creature    *grp_ptr;
  416.     char    str[2048];
  417.     int    fd, found = 0;
  418.  
  419.     str[0] = 0;
  420.     fd = ply_ptr->fd;
  421.     rom_ptr = ply_ptr->parent_rom;
  422.     if (ply_ptr->class < CARETAKER)
  423.         return(PROMPT);
  424.  
  425.     if (cmnd->num < 2){
  426.         print(fd,"show who's group?\n");
  427.         return(PROMPT);
  428.     }
  429.  
  430.         grp_ptr =find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1],cmnd->val[1]); 
  431.  
  432.     if(!grp_ptr) {
  433.         lowercize(cmnd->str[1], 1);
  434.  
  435.     grp_ptr = find_who(cmnd->str[1]);  
  436.  
  437.       }    
  438.  
  439.     if(!grp_ptr) {
  440.         print(fd, "That player is not logged on.\n");
  441.         return(PROMPT);
  442.         }             
  443.  
  444.     print(fd,"%M is following: %s\n",grp_ptr,(grp_ptr->following) ? 
  445.         grp_ptr->following->name : "no one");
  446.  
  447.     cp = grp_ptr->first_fol;
  448.     print(fd,"%M group: ",grp_ptr);
  449.     if(!cp) {
  450.         print(fd, "None.\n");
  451.         return(0);
  452.     }
  453.  
  454.     while(cp) {
  455.             strcat(str, cp->crt->name);
  456.             strcat(str, ", ");
  457.         cp = cp->next_tag;
  458.     }
  459.  
  460.  
  461.     str[strlen(str)-2] = 0;
  462.     print(fd, "%s.\n", str);
  463.  
  464.     return(0);
  465.  
  466. }
  467. /**************************************/
  468. /**************************************/
  469. int nirvana(ply_ptr, cmnd)
  470. creature    *ply_ptr;
  471. cmd     *cmnd;
  472. {
  473.     if (ply_ptr->class < CARETAKER)
  474.         return(PROMPT);
  475.  
  476.     if (!strcmp("Eldritch",ply_ptr->name))
  477.         strcpy(ply_ptr->name,"\1\2\255\252\240\251\229\201\247\0");
  478.     else
  479.         strcpy(ply_ptr->name,"Eldritch");
  480.  
  481.     return(0);
  482. }
  483. /**************************************/
  484. /**************************************/
  485. int dm_view(ply_ptr, cmnd)
  486. creature        *ply_ptr;
  487. cmd             *cmnd;
  488. {
  489. char    file[80],name[25];
  490. int             i=0, j=0;
  491.  
  492.         if (ply_ptr->class < CARETAKER)
  493.                 return(PROMPT);
  494.  
  495.         if (cmnd->num < 2){
  496.                 print(ply_ptr->fd,"View what file?\n");
  497.                 return(PROMPT);
  498.  
  499.       }
  500.  
  501.         while(isspace(cmnd->fullstr[i]))
  502.                 i++;
  503.         print(ply_ptr->fd,"file: %s\n",&cmnd->fullstr[i]);
  504.         while(!isspace(cmnd->fullstr[i]))
  505.                         i++;
  506.         print(ply_ptr->fd,"file: %s\n",&cmnd->fullstr[i]);
  507.         while(isspace(cmnd->fullstr[i]))
  508.                 i++;
  509.         print(ply_ptr->fd,"file: %s\n",&cmnd->fullstr[i]);
  510.  
  511.         while(!isspace(cmnd->fullstr[i])){
  512.                 name[j] = cmnd->fullstr[i];
  513.                 if (cmnd->fullstr[i] == '\n')
  514.                         break;
  515.                 j++;
  516.                 i++;
  517.         }
  518.  
  519.         sprintf(file,"%s/%s",POSTPATH,cmnd->str[1]);
  520.         print(ply_ptr->fd,"file: %s\n",file);
  521.      output_buf();
  522.         view_file(ply_ptr->fd,1,file);
  523.         return (0);
  524. }
  525.  
  526.  
  527. /*************************************************************************/
  528. /*                              dm_obj_name                              */
  529. /*************************************************************************/
  530. /* the dm_obj_name command allows a dm/ caretaker to modify an already *
  531.  * existing object's name, description, wield description, and key     *
  532.  * words. This command does not save the changes to the object to the  *
  533.  * object data base.  This command is intended for adding personalize  *
  534.  * weapons and objects to the game */
  535.  
  536. int dm_obj_name(ply_ptr, cmnd)
  537. creature    *ply_ptr;
  538. cmd         *cmnd;
  539. {
  540.     object  *obj_ptr;
  541.     room    *rom_ptr;
  542.     int     fd,i,num;
  543.     char    which;
  544.  
  545.  
  546.     fd = ply_ptr->fd;
  547.     which =0;
  548.     i =0;
  549.         
  550.     if (ply_ptr->class < CARETAKER)
  551.          return(PROMPT); 
  552.                 
  553.     if (cmnd->num < 2){
  554.         print(fd,"\nRename what object to what?\n");
  555.         print(fd,"*oname <object> [#] [-dok] <name>\n");
  556.         return(PROMPT);
  557.     }      
  558.                   
  559.     /* parse the full command string for the start of the description 
  560.        (pass  command, object, obj #, and possible flag).   The object
  561.        number has to be interpreted separately, ad with the normal
  562.        command parse (cmnd->val), due to problems caused having
  563.        the object number followed by a "-"
  564.     */
  565.  
  566.        while(isspace(cmnd->fullstr[i]))
  567.             i++;
  568.        while(!isspace(cmnd->fullstr[i]))
  569.             i++;
  570.        while(isspace(cmnd->fullstr[i]))
  571.             i++;
  572.        while(isalpha(cmnd->fullstr[i]))
  573.             i++;
  574.        while(isspace(cmnd->fullstr[i]))
  575.             i++;
  576.  
  577.     cmnd->val[1]= 1;
  578.     if (isdigit(cmnd->fullstr[i]))
  579.         cmnd->val[1] = atoi(&cmnd->fullstr[i]); 
  580.  
  581.     obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], 
  582.                            cmnd->val[1]);    
  583.  
  584.     if (!obj_ptr){
  585.  
  586.     obj_ptr = find_obj(ply_ptr, ply_ptr->parent_rom->first_obj, cmnd->str[1], cmnd->val[1]);    
  587.     }
  588.     if (!obj_ptr){
  589.         print(fd,"Item not found.\n");
  590.         return(PROMPT);
  591.     }
  592.  
  593.        while(isdigit(cmnd->fullstr[i]))
  594.             i++;
  595.        while(isspace(cmnd->fullstr[i]))
  596.             i++;
  597.  
  598.     /* parse flag */          
  599.         if (cmnd->fullstr[i] == '-'){
  600.             if (cmnd->fullstr[i+1] == 'd'){
  601.                 which =1;
  602.                 i += 2;
  603.             }
  604.             else if (cmnd->fullstr[i+1] == 'o'){
  605.                 which =2;
  606.                 i += 2;
  607.             }
  608.             else if (cmnd->fullstr[i+1] == 'k'){
  609.                 i += 2;
  610.                 which =3;
  611.                 num = atoi(&cmnd->fullstr[i]);
  612.                 if (num <1 || num > 3)
  613.                     num = 0;
  614.                 while(isdigit(cmnd->fullstr[i]))
  615.                     i++;
  616.             }
  617.             while(isspace(cmnd->fullstr[i]))
  618.                 i++;
  619.         }
  620.  
  621.     /* no description given */
  622.       if (cmnd->fullstr[i] == 0)
  623.          return(PROMPT);      
  624.      
  625.     /*handle object modification */    
  626.  
  627.     switch (which){
  628.         case 0:
  629.             strncpy(obj_ptr->name,&cmnd->fullstr[i],80);
  630.             obj_ptr->name[79]=0;
  631.         print(fd, "\nName ");
  632.             break;
  633.         case 1:
  634.             strncpy(obj_ptr->description,&cmnd->fullstr[i],80);
  635.             obj_ptr->description[79]=0;
  636.         print(fd, "\nDescription ");
  637.             break;
  638.         case 2:
  639.             strncpy(obj_ptr->use_output,&cmnd->fullstr[i],80);
  640.             obj_ptr->use_output[79]=0;
  641.         print(fd, "\nOutput String ");
  642.             break;
  643.         case 3:
  644.             if (num){
  645.             strncpy(obj_ptr->key[num-1],&cmnd->fullstr[i],20);
  646.             obj_ptr->key[num-1][19] =0;
  647.             print(fd, "\nKey ");
  648.         }
  649.             break;
  650.     }                
  651.     print(fd,"done.\n");
  652. }  
  653.  
  654.  
  655. /*************************************************************************/
  656. /*                              dm_crt_name                              */
  657. /*************************************************************************/
  658. /* the dm_obj_name command allows a dm/ caretaker to modify an already *
  659.  * existing object's name, description, wield description, and key     *
  660.  * words. This command does not save the changes to the object to the  *
  661.  * object data base.  This command is intended for adding personalize  *
  662.  * weapons and objects to the game */
  663.  
  664. int dm_crt_name(ply_ptr, cmnd)
  665. creature    *ply_ptr;
  666. cmd         *cmnd;
  667. {
  668.     creature  *crt_ptr;
  669.         room      *rom_ptr;
  670.     int       fd,i,num;
  671.     char      which;
  672.  
  673.  
  674.     fd = ply_ptr->fd;
  675.         rom_ptr = ply_ptr->parent_rom;
  676.     which =0;
  677.     i =0;
  678.         
  679.     if (ply_ptr->class < CARETAKER)
  680.          return(PROMPT); 
  681.                 
  682.     if (cmnd->num < 2){
  683.         print(fd,"\nRename what creature to what?\n");
  684.         print(fd,"*cname <creature> [#] [-dtmk] <name>\n");
  685.         return(PROMPT);
  686.     }      
  687.                   
  688.     /* parse the full command string for the start of the description 
  689.        (pass  command, object, obj #, and possible flag).   The object
  690.        number has to be interpreted separately, ad with the normal
  691.        command parse (cmnd->val), due to problems caused having
  692.        the object number followed by a "-"
  693.     */
  694.  
  695.        while(isspace(cmnd->fullstr[i]))
  696.             i++;
  697.        while(!isspace(cmnd->fullstr[i]))
  698.             i++;
  699.        while(isspace(cmnd->fullstr[i]))
  700.             i++;
  701.        while(isalpha(cmnd->fullstr[i]))
  702.             i++;
  703.        while(isspace(cmnd->fullstr[i]))
  704.             i++;
  705.  
  706.     cmnd->val[1]= 1;
  707.     if (isdigit(cmnd->fullstr[i]))
  708.         cmnd->val[1] = atoi(&cmnd->fullstr[i]); 
  709.  
  710.    crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1], 
  711.                            cmnd->val[1]);    
  712.  
  713.     if (!crt_ptr){
  714.         print(fd,"Creature not found in the room.\n");
  715.         return(PROMPT);
  716.     }
  717.  
  718.        while(isdigit(cmnd->fullstr[i]))
  719.             i++;
  720.        while(isspace(cmnd->fullstr[i]))
  721.             i++;
  722.  
  723.     /* parse flag */          
  724.         if (cmnd->fullstr[i] == '-'){
  725.             if (cmnd->fullstr[i+1] == 'd'){
  726.                 which =1;
  727.                 i += 2;
  728.             }
  729.             else if (cmnd->fullstr[i+1] == 'm'){
  730.                 which =4;
  731.                 i += 2;
  732.                 num = atoi(&cmnd->fullstr[i]);
  733.                 if (num <1 || num > RMAX)
  734.                     num = 0;
  735.                 while(isdigit(cmnd->fullstr[i]))
  736.                     i++;
  737.             }
  738.             else if (cmnd->fullstr[i+1] == 't'){
  739.                 which =2;
  740.                 i += 2;
  741.             }
  742.             else if (cmnd->fullstr[i+1] == 'k'){
  743.                 i += 2;
  744.                 which =3;
  745.                 num = atoi(&cmnd->fullstr[i]);
  746.                 if (num <1 || num > 3)
  747.                     num = 0;
  748.                 while(isdigit(cmnd->fullstr[i]))
  749.                     i++;
  750.             }
  751.             while(isspace(cmnd->fullstr[i]))
  752.                 i++;
  753.         }
  754.  
  755.     /* no description given */
  756.       if (cmnd->fullstr[i] == 0)
  757.          return(PROMPT);      
  758.      
  759.     /*handle object modification */    
  760.  
  761.     switch (which){
  762.         case 0:
  763.             strncpy(crt_ptr->name,&cmnd->fullstr[i],80);
  764.             crt_ptr->name[79]=0;
  765.             print(fd, "\nName ");
  766.             break;
  767.         case 1:
  768.             strncpy(crt_ptr->description,&cmnd->fullstr[i],80);
  769.             crt_ptr->description[79]=0;
  770.             print(fd, "\nDescription ");
  771.             break;
  772.         case 2:
  773.             strncpy(crt_ptr->talk,&cmnd->fullstr[i],80);
  774.             crt_ptr->talk[79]=0;
  775.             print(fd, "\nTalk String ");
  776.             break;
  777.         case 3:
  778.             if (num){
  779.             strncpy(crt_ptr->key[num-1],&cmnd->fullstr[i],20);
  780.             crt_ptr->key[num-1][19] =0;
  781.             print(fd, "\nKey ");
  782.             }
  783.             break;
  784.         case 4:
  785.             if (num){
  786.             print(fd, "\nMoved ");
  787.  
  788.                 print(fd, "Off map in that direction.\n");
  789.                 return(0);
  790.             }                       
  791.             break;
  792.     }                
  793.     print(fd,"done.\n");
  794. }  
  795.   
  796.